#include "stdafx.h"
#include "CSignalBar.h"


CSignalBar* CSignalBar::m_pInstance = 0;
CSignalBar::CSignalBar(const WCHAR * szBmpName,RECT rct,const WCHAR * name):CProgressBar(szBmpName,rct,name)
{
	m_pos=0;
}

CSignalBar::~CSignalBar(void)
{
}

CSignalBar* CSignalBar::getInstance(const WCHAR * szBmpName ,RECT rct,WCHAR * name)
{
	if (!m_pInstance)
		m_pInstance = new CSignalBar(szBmpName,rct,name);
	return m_pInstance;

}
void CSignalBar::draw(HDC * hdc)
{
	if (!m_hBmp)
		m_hBmp = GlobalStatic::LoadBmpRes(m_strBmp.c_str());
	if (!m_hDC)
	{
		m_hDC = CreateCompatibleDC(*hdc);
	}

	SetBkColor(m_hDC,RGB(255,0,255));
	HBITMAP hOldBmp = (HBITMAP)SelectObject(m_hDC, m_hBmp);


	if (m_bVisible && m_bNeedUpdate)
	{
		int h = (m_RectPos.right-m_RectPos.left)*m_pos;
		TransparentBlt(*hdc, m_RectPos.left,m_RectPos.top,\
			m_RectPos.right-m_RectPos.left,m_RectPos.bottom - m_RectPos.top,\
			m_hDC, h,0,\
			m_RectPos.right-m_RectPos.left,\
			m_RectPos.bottom - m_RectPos.top, TRANSPARENTCOLOR);
		m_bNeedUpdate = false;
	}
	SelectObject(m_hDC, hOldBmp);
}